package com.rqf.mr.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.rqf.mr.service.IBedService;
import com.rqf.mr.service.IDrugService;
import com.rqf.mr.service.IOrderService;
import com.rqf.mr.service.IPatientService;
import com.rqf.mr.service.impl.DrugService;
import com.server.web.JSONSerielizer;
import com.server.web.OutputUtil;

/**
 * 瓶签
 * @author HelloWorld_luo
 * @date 2016年5月4日
 */
@Controller
@RequestMapping("drug")
public class DrugController {

	@Autowired
	private IDrugService drugService;

	@RequestMapping("list/notExecute/{orgId}/{inpatiId}")
	public void getNotExecuteList(HttpServletRequest request,
			HttpServletResponse response, @PathVariable String orgId, @PathVariable String inpatiId) {
		List<Map<String, Object>> list = drugService.getDrugPlanListFromEhisView(inpatiId);
		String json = JSONSerielizer.toJson(list, null, null);
		OutputUtil.returnJsonp(request, response, json);
	}
	
	@RequestMapping("list/executed/{inpatiId}")
	public void getExecutedList(HttpServletRequest request,
			HttpServletResponse response, @PathVariable String inpatiId) {
		List<Map<String, Object>> list = drugService.getDrugPlanListFromTabDrugPlan(inpatiId);
		String json = JSONSerielizer.toJson(list, null, null);
		OutputUtil.returnJsonp(request, response, json);
	}
	
	@RequestMapping("execute/{orderId}/{nurseLoginId}")
	public void executeOrder(HttpServletRequest request,HttpServletResponse response,
			@PathVariable String orderId, @PathVariable String nurseLoginId){
		Boolean result = false;
		result = drugService.executeOrderByNurseLoginId(orderId, nurseLoginId);
		OutputUtil.returnJsonp(request, response, result.toString());
	}
	
	@RequestMapping("info/{orderId}")
	public void getDrugInfo(HttpServletRequest request,HttpServletResponse response,
			@PathVariable String orderId){
		List<Map<String, Object>> list = drugService.getDrugInfoByOrderid(orderId);
		String json = JSONSerielizer.toJson(list, null, null);
		OutputUtil.returnJsonp(request, response, json);
	}
	
}
